<?php
namespace app\mobile\controller;

use app\model\Comm; 
use app\model\Theme; 

class Getopenredbag extends Base
{
    public function Getopenredbag()
    {
global $_G, $_P;
$system    = $_G['system'];
$fans = $this->checkuser();
$themeid = intval($_P['themeid']);
if($themeid <= 0){
    return_msg('活动入口不正确');
}
$theme = Theme::getThemeById($themeid);
$config = Theme::getConfig($themeid);
if(!empty($fans) && !empty($config)){
    $money = Comm::getopenredbag($system,$config);
}
if ($money>0){
    $url = $_G['siteroot'].createMobileUrl('mycomm',array('themeid'=>$themeid));
    $endtime = date('m/d/Y H:i:s',$theme['endtime']);
    $ishbopen = true;
    if ($config['myredbagstyle']==0){
        $txt = <<<EOF
<div class="banner ">
        <div  style="width: 80%;    margin: 10px auto;line-height: 40px;" class=" myhold">
            <a class=" jlink" style="font-size: 20px;text-align: center; color: #fff;"  href="{$url}">我的&#32418;&#x5305;【{$money}元】  去&#25552;&#x73B0;</a>
        </div>
    </div>
EOF;
    }else{
    $txt = <<<EOF
            <div class="timeBar" >
                <div class="balanceMoney" >
                    &#x7EA2;&#21253;：<span>{$money}</span>
                </div >
                <div class="timeLast" >
                    <h2 > 失效倒计时</h2 >
                    <div class="yomibox mobile_color" endtime = "{$endtime }" ></div >
                </div >
                <div class="balanceBtn" >
                    <a href = "javascript:goPick()" class="goPick" > 去&#25552;&#x73B0;</a>
                    <a href = "{$url}" class="balanceInfor" >&#x7EA2;&#21253;明细</a>
                </div>
            </div>
EOF;
}
    $balanceMoney = Theme::encode($txt);

}else{
    $ishbopen = false;
}
$result = array(
    "errcode"=>$ishbopen,
    "money"=> sprintf("%.2f",$money),
    "balanceMoney"=>$balanceMoney
);
return_msg($result, '', 'ajax');
}
}